package com.musicalevents.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.hibernate.sql.JoinType;

import com.musicalevents.dao.UserDAO;
import com.musicalevents.entity.User;

public class UserDAOImpl extends GenericDAOImpl<User, Integer> implements UserDAO {

	public UserDAOImpl(Class<User> type) {
		super(type);
	}

	public User findByLogin(String login) {
		Criteria crit = getSession().createCriteria(User.class);
		crit.add(Restrictions.eq("login", login));
		crit.createAlias("role", "r", JoinType.INNER_JOIN);
		User u = (User) crit.uniqueResult();
		return (u);
	}

}
